package refactortips.editors.codeSmells;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.wb.swt.ResourceManager;
import org.eclipse.wb.swt.SWTResourceManager;

import refactortips.editors.AbstractRefactorTipsEditor;
import refactortips.editors.CommandMouseAdapter;

public class LargeClassEditor extends AbstractRefactorTipsEditor {

	protected final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
	
	public LargeClassEditor() {
	}

	/**
	 * Create contents of the editor part.
	 * @param parent
	 */
	@Override
	public void createPartControl(Composite parent) {
		
		Form frmCodeSmell = formToolkit.createForm(parent);
		formToolkit.paintBordersFor(frmCodeSmell);
		frmCodeSmell.setText("Large Class");
		frmCodeSmell.getBody().setLayout(new FillLayout(SWT.HORIZONTAL));
		
		TabFolder tabFolder = new TabFolder(frmCodeSmell.getBody(), SWT.NONE);
		formToolkit.adapt(tabFolder);
		formToolkit.paintBordersFor(tabFolder);
		
		ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
		sc.setExpandHorizontal(true);
	    sc.setExpandVertical(true);
		
		TabItem tbtmDescription = new TabItem(tabFolder, SWT.NONE);
		tbtmDescription.setText("Descri\u00E7\u00E3o");
		
		ScrolledComposite scrolledComposite = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		tbtmDescription.setControl(scrolledComposite);
		formToolkit.paintBordersFor(scrolledComposite);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		
		Composite composite_3 = new Composite(scrolledComposite, SWT.NONE);
		formToolkit.adapt(composite_3);
		formToolkit.paintBordersFor(composite_3);
		composite_3.setLayout(null);
		
		Label lblDescription = new Label(composite_3, SWT.NONE);
		lblDescription.setBounds(10, 10, 102, 25);
		lblDescription.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
		lblDescription.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
		formToolkit.adapt(lblDescription, true, true);
		lblDescription.setText("Descri\u00E7\u00E3o");
		
		Label lblImageDontRepeat = new Label(composite_3, SWT.NONE);
		lblImageDontRepeat.setImage(ResourceManager.getPluginImage("RefactorTips", "images/codeSmells/largeClass.png"));
		lblImageDontRepeat.setBounds(47, 96, 500, 337);
		formToolkit.adapt(lblImageDontRepeat, true, true);
		
		Link linkExtractClass1 = new Link(composite_3, SWT.NONE);
		linkExtractClass1.setBounds(701, 182, 86, 21);
		linkExtractClass1.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkExtractClass1.addMouseListener(new CommandMouseAdapter(getSite(), "RefactorTips.commands.extractClassCommand"));
		formToolkit.adapt(linkExtractClass1, true, true);
		linkExtractClass1.setText("<a>Extract Class</a>");
		
		Link linkExtractSubclass1 = new Link(composite_3, 0);
		linkExtractSubclass1.setText("<a>Extract Subclass</a>");
		linkExtractSubclass1.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkExtractSubclass1.setBounds(583, 433, 110, 21);
		formToolkit.adapt(linkExtractSubclass1, true, true);
		
		Link linkExtractClass2 = new Link(composite_3, 0);
		linkExtractClass2.addMouseListener(new CommandMouseAdapter(getSite(), "RefactorTips.commands.extractClassCommand"));
		linkExtractClass2.setText("<a>Extract Class</a>");
		linkExtractClass2.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkExtractClass2.setBounds(138, 493, 86, 21);
		formToolkit.adapt(linkExtractClass2, true, true);
		
		Link linkExtractSubclass2 = new Link(composite_3, 0);
		linkExtractSubclass2.setText("<a>Extract Subclass</a>");
		linkExtractSubclass2.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkExtractSubclass2.setBounds(261, 493, 110, 21);
		formToolkit.adapt(linkExtractSubclass2, true, true);
		
		Link linkExtractClass3 = new Link(composite_3, 0);
		linkExtractClass3.addMouseListener(new CommandMouseAdapter(getSite(), "RefactorTips.commands.extractClassCommand"));
		linkExtractClass3.setText("<a>Extract Class</a>");
		linkExtractClass3.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkExtractClass3.setBounds(73, 659, 86, 21);
		formToolkit.adapt(linkExtractClass3, true, true);
		
		Link linkExtractSubclass3 = new Link(composite_3, 0);
		linkExtractSubclass3.setText("<a>Extract Subclass</a>");
		linkExtractSubclass3.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkExtractSubclass3.setBounds(214, 659, 110, 21);
		formToolkit.adapt(linkExtractSubclass3, true, true);
		
		Link linkExtractInterface = new Link(composite_3, 0);
		linkExtractInterface.setText("<a>Extract Interface</a>");
		linkExtractInterface.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkExtractInterface.addMouseListener(new CommandMouseAdapter(getSite(), "RefactorTips.commands.extractInterfaceCommand"));
		linkExtractInterface.setBounds(61, 682, 110, 21);
		formToolkit.adapt(linkExtractInterface, true, true);
		
		Link linkDuplicateObservedData = new Link(composite_3, 0);
		linkDuplicateObservedData.setText("<a>Duplicate Observed Data</a>");
		linkDuplicateObservedData.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		linkDuplicateObservedData.setBounds(135, 763, 172, 21);
		formToolkit.adapt(linkDuplicateObservedData, true, true);
		
		StyledText styledText = new StyledText(composite_3, SWT.READ_ONLY | SWT.WRAP);
		styledText.setEnabled(false);
		styledText.setDoubleClickEnabled(false);
		styledText.setJustify(true);
		styledText.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		styledText.setText("\t\tQuando uma classe est\u00E1 tentando fazer muita coisa, geralmente esta tem muitas vari\u00E1veis de inst\u00E2ncia. Quando uma classe tem muitas vari\u00E1veis de inst\u00E2ncia, c\u00F3digo duplicado n\u00E3o pode estar muito longe.");
		styledText.setBounds(578, 66, 320, 113);
		formToolkit.adapt(styledText);
		formToolkit.paintBordersFor(styledText);
		
		StyledText styledText_1 = new StyledText(composite_3, SWT.READ_ONLY | SWT.WRAP);
		styledText_1.setText("\t\tVoc\u00EA pode\t\t\t\t\t\t  para agrupar v\u00E1rias vari\u00E1veis. Escolha as vari\u00E1veis que combinam no componente que faz sentido para cada uma. Por exemplo, \u201CvalorDoDeposito\u201D e \u201CmoedaDoDeposito\u201D possivelmente pertencem juntos em um componente. De forma mais geral, prefixos ou sufixos comuns para algum subconjunto de vari\u00E1veis em uma classe sugere a oportunidade de um novo componente. Se o componente fizer sentido como uma subclasse, voc\u00EA ir\u00E1 perceber que\t\t\t   \t\t\t\t\t\t\t\tnormalmente \u00E9 mais f\u00E1cil.");
		styledText_1.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		styledText_1.setEnabled(false);
		styledText_1.setJustify(true);
		styledText_1.setDoubleClickEnabled(false);
		styledText_1.setBounds(578, 182, 320, 293);
		formToolkit.adapt(styledText_1);
		formToolkit.paintBordersFor(styledText_1);
		
		StyledText styledText_2 = new StyledText(composite_3, SWT.READ_ONLY | SWT.WRAP);
		styledText_2.setText("\t\tAlgumas vezes uma classe n\u00E3o usa todas as suas vari\u00E1veis de inst\u00E2ncia o tempo todo. Se for esse o caso, talvez voc\u00EA possa\t\t\t\t\t\t\tou \t\t\t\t\t\t\t\tmuitas vezes.");
		styledText_2.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		styledText_2.setEnabled(false);
		styledText_2.setJustify(true);
		styledText_2.setDoubleClickEnabled(false);
		styledText_2.setBounds(59, 471, 824, 46);
		formToolkit.adapt(styledText_2);
		formToolkit.paintBordersFor(styledText_2);
		
		StyledText styledText_3 = new StyledText(composite_3, SWT.READ_ONLY | SWT.WRAP);
		styledText_3.setText("\t\tAssim como uma classe com muitas vari\u00E1veis de inst\u00E2ncia, uma classe com muito c\u00F3digo \u00E9 o in\u00EDcio de um terreno f\u00E9rtil para c\u00F3digo duplicado, caos e morte. A solu\u00E7\u00E3o mais simples \u00E9 eliminar a redund\u00E2ncia na classe em si. Se voc\u00EA tem m\u00E9todos com 500 linhas de c\u00F3digo com v\u00E1rios c\u00F3digos em comum, talvez voc\u00EA possa transform\u00E1-los em m\u00E9todos de 5 ou 10 linhas com outros m\u00E9todos de 10 ou 2 linhas extra\u00EDdos do original.");
		styledText_3.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		styledText_3.setEnabled(false);
		styledText_3.setJustify(true);
		styledText_3.setDoubleClickEnabled(false);
		styledText_3.setBounds(59, 531, 837, 89);
		formToolkit.adapt(styledText_3);
		formToolkit.paintBordersFor(styledText_3);
		
		StyledText styledText_4 = new StyledText(composite_3, SWT.READ_ONLY | SWT.WRAP);
		styledText_4.setText("\t\tAssim como uma classe com muitas vari\u00E1veis, a solu\u00E7\u00E3o mais comum para uma classe com muito c\u00F3digo \u00E9 tanto \t\t\t\t\t\tor \t\t\t\t\t\t\t\t. Um artif\u00EDcio \u00FAtil \u00E9 determinar como clientes usam a classe e usar \t\t\t\t\t\t\t\tpara cada um desses casos. Isso talvez lhe d\u00EA ideias de como voc\u00EA pode dividir a classe ainda mais.");
		styledText_4.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		styledText_4.setEnabled(false);
		styledText_4.setJustify(true);
		styledText_4.setDoubleClickEnabled(false);
		styledText_4.setBounds(61, 638, 837, 69);
		formToolkit.adapt(styledText_4);
		formToolkit.paintBordersFor(styledText_4);
		
		StyledText styledText_5 = new StyledText(composite_3, SWT.READ_ONLY | SWT.WRAP);
		styledText_5.setText("\t\tSe sua classe grande \u00E9 uma classe da GUI, talvez voc\u00EA precise mover os dados e o comportamento para um objeto de dom\u00EDnio separado. Isso talvez requeira algum dado duplicado em ambos os lugares e manter os dados em sincronia.\t\t\t\t\t\t\t\t\t\t\t\tsugere como fazer isso.");
		styledText_5.setFont(SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL));
		styledText_5.setEnabled(false);
		styledText_5.setJustify(true);
		styledText_5.setDoubleClickEnabled(false);
		styledText_5.setBounds(61, 722, 837, 107);
		formToolkit.adapt(styledText_5);
		formToolkit.paintBordersFor(styledText_5);
		scrolledComposite.setContent(composite_3);
		scrolledComposite.setMinSize(composite_3.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		TabItem tbtmUsage = new TabItem(tabFolder, SWT.NONE);
		tbtmUsage.setText("Exemplo");
		
		ScrolledComposite scrolledComposite_1 = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
		tbtmUsage.setControl(scrolledComposite_1);
		formToolkit.paintBordersFor(scrolledComposite_1);
		scrolledComposite_1.setExpandHorizontal(true);
		scrolledComposite_1.setExpandVertical(true);
		
		Composite composite = new Composite(scrolledComposite_1, SWT.NONE);
		formToolkit.adapt(composite);
		formToolkit.paintBordersFor(composite);
		scrolledComposite_1.setContent(composite);
		scrolledComposite_1.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		TabItem tbtmVideo = new TabItem(tabFolder, SWT.NONE);
		tbtmVideo.setText("Video");
		
		Browser browser = new Browser(tabFolder, SWT.NONE);
		browser.setUrl("");
		tbtmVideo.setControl(browser);
		formToolkit.paintBordersFor(browser);
	}
}
